<%--
  Created by IntelliJ IDEA.
  User: Yang
  Date: 2021/11/25
  Time: 10:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<%@include file="common/devhead.jsp"%>
<body>
<div class="row">
    <div class="col-md-12 col-sm-12 col-xs-12">
        <div class="x_panel">
            <div class="x_title">
                <h2>Form validation <small>sub title</small></h2>
                <ul class="nav navbar-right panel_toolbox">
                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="#">Settings 1</a>
                            </li>
                            <li><a href="#">Settings 2</a>
                            </li>
                        </ul>
                    </li>
                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                    </li>
                </ul>
                <div class="clearfix"></div>
            </div>
            <div class="x_content">
                <form action="${pageContext.request.contextPath}/appInfo/appInfoAdd" class="form-horizontal form-label-left" novalidate enctype="multipart/form-data" method="post">
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="softwareName">手游名称 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input  class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" id="softwareName" name="softwareName" placeholder="请输入手游名称" required="required" type="text">
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="APKName">APK名称 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="APKName" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="APKName" placeholder="请输入APK名称" required="required" type="text">
                            <span class="apknameExist"></span>
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="supportRom">支持ROM <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="supportRom" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="supportRom" placeholder="请输入APK名称" required="required" type="text">
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="interfaceLanguage">界面语言 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="interfaceLanguage" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="interfaceLanguage" placeholder="请输入手游支持的界面语言" required="required" type="text">
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="softwareSize">手游大小 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="softwareSize" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="softwareSize" placeholder="请输入手游大小、单位为Mb" required="required" type="text">
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="downloads">下载次数 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="downloads" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="downloads" placeholder="请输入下载次数" required="required" type="text">
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" >所属平台 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <select class="form-control"  name="flatformId">
                                <option value="0">请选择</option>
                                <c:forEach items="${ddry}" var="dd">
                                    <c:if test="${flatformId==dd.valueId}">
                                        <option value="${dd.valueId}" selected="selected">${dd.valueName}</option>
                                    </c:if>
                                    <c:if test="${status!=dd.valueId}">
                                        <option value="${dd.valueId}">${dd.valueName}</option>
                                    </c:if>

                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="categoryLevel1">一级分类 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <select class="form-control" name="categoryLevel1" id="categoryLevel1" onchange="fenlei"></select>
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="categoryLevel2">二级分类 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <select class="form-control" name="categoryLevel2" id="categoryLevel2" onchange="fenlei"></select>
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="categoryLevel3">三级分类 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <select class="form-control" name="categoryLevel3" id="categoryLevel3" onchange="fenlei"></select>
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="status">手游状态 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <span>待审核</span>
                            <input type="hidden" value="1" name="status" id="status"/>
                           <%-- <input type="hidden" name="devId" value="${devName.id}">
                            <input type="hidden" name="createdBy" value="${devName.id}">--%>
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="appInfo">应用简介 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">

                                           <textarea id="appInfo" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="appInfo" placeholder="请输入本手游的相关性信息，本信息作为手游的详细介绍" required="required" type="text">
                                           </textarea>
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">LOGO图片 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input type="hidden" id="errorinfo" value="${uploadError}">
                            <input type="file" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="picPath" id="logoPicPath"/>
                        </div>
                    </div>
                    <div class="ln_solid"></div>
                    <div class="form-group">
                        <div class="col-md-6 col-md-offset-3">
                            <button id="send" type="submit" class="btn btn-success">保存</button>
                            <button href="${pageContext.request.contextPath}/appInfo/devappInfoList" id="back" class="btn btn-primary">返回</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
</div>
</div>
</body>
<%@include file="common/devfoot.jsp"%>
<script src="${pageContext.request.contextPath}/statics/js/jquery-1.12.4.js"></script>
<script>

    var option=null
    var path='${pageContext.request.contextPath}';
    $("#APKName").blur(function (){
        $.getJSON(path+"/appInfo/APKNameExist","APKName="+$("#APKName").val(),function (data){
            if (data.APKName=="true"){
                $(".apknameExist").html("该APK名称可以使用");
            }else {
                $(".apknameExist").html("该APK名称已存在");
            }
        })
    })
    var backBtn=null;
    $(function () {

        $.getJSON(path+"/category/fenlei1",'',function (data){
            option="<option value='0'>请选择</option>";
            for (var i = 0; i < data.length; i++) {
                if($("#level1").val()==+data[i].id){
                    option+="<option selected='selected' value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                }else {
                    option+="<option value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                }
            }
            $("#categoryLevel1").html(option);
        })
        $.ajax({
            type: "GET",
            url:path+"/category/fenlei2",
            data:{parentId:$("#level1").val()},
            dataType:"json",
            success:function (data){
                option="<option value='0'>请选择</option>";
                for (var i = 0; i < data.length; i++) {
                    if($("#level2").val()==data[i].id){
                        option+="<option selected='selected' value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                    }else{
                        option+="<option value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                    }
                }
                $("#categoryLevel2").html(option);
            }
        })
        $.getJSON(path+"/category/fenlei3",{parentId:$("#level2").val()},function (data){
            option="<option value='0'>请选择</option>";
            for (var i = 0; i < data.length; i++) {
                if($("#level3").val()==+data[i].id){
                    option+="<option selected='selected' value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                }else {
                    option+="<option value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                }
            }
            $("#categoryLevel3").html(option);
        })

        $.getJSON(path+"/category/fenlei1",'',function (data){
            option="<option value='0'>请选择</option>";
            for (var i = 0; i < data.length; i++) {
                option+="<option value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
            }
            $("#categoryLevel1").html(option);

        })
        $("#categoryLevel1").change(function (){
            var categoryLevel1=$("#categoryLevel1").val();
            if(categoryLevel1!="" && categoryLevel1!=null){
                $.ajax({
                    type: "GET",
                    url:path+"/category/fenlei2",
                    data:{parentId:categoryLevel1},
                    dataType:"json",
                    success:function (data){
                        option="<option value='0'>请选择</option>";
                        for (var i = 0; i < data.length; i++) {
                            option+="<option value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                        }
                        $("[name=categoryLevel2]").html(option);
                        $("#categoryLevel2").html(option);
                    },
                    error:function (data){
                        alert("加载二级菜单失败")
                    }
                })
            }else{
                $("#categoryLevel2").html("");
                option="<option value='0'>请选择</option>";
                $("#categoryLevel2").html(option);
            }
            $("#categoryLevel3").html("");
            option="<option value='0'>请选择</option>";
            $("#categoryLevel3").html(option);
        })
        $("#categoryLevel2").change(function (){
            var categoryLevel2=$("#categoryLevel2").val();
            if(categoryLevel2!="" && categoryLevel2!=null) {
                $.ajax({
                    type: "GET",
                    url: path+"/category/fenlei3",
                    data: {parentId: categoryLevel2},
                    dataType: "json",
                    success: function (data) {
                        option = "<option value='0'>请选择</option>";
                        for (var i = 0; i < data.length; i++) {
                            option += "<option value='" + data[i].id + "'>" + data[i].categoryName + "</option>"
                        }
                        $("#categoryLevel3").html(option);
                    },
                    error:function (data){
                        alert("加载三级菜单失败")
                    }
                })
            }
        })

        var logoPicPath=null;
        var errorinfo=null;

        $(function (){
            logoPicPath=$("#logoPicPath").val();
            errorinfo=$("#errorinfo").val();
            if (errorinfo.val()==null||errorinfo.val()==""){
                logoPicPath.next().html(
                    "*上传大小不能超过50MB* 上传文件类型必须为：.jpg、.png、.jpeg、pneg"
                );
            }else{
                logoPicPath.next().html(errorinfo.val());
            }

        })
    })
</script>
</html>
